﻿@using JinJun.YShow.Model;
@{
    Layout = null;
    var OrderInfo = ViewBag.OrderInfo as OrderQuery;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>品牌添加--layui后台管理模板</title>
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="format-detection" content="telephone=no" />
    <link rel="stylesheet" href="~/layui-v2.5.4/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="~/static/admin/css/style.css">
    <link rel="stylesheet" href="~/layui-v2.5.4/layui/css/modules/layer/default/layer.css" media="all" />
</head>
<body class="childrenBody">
    <form class="layui-form" style="width:80%;">
        <input type="hidden" value="@OrderInfo.Order_Id" id="Id" />
        @*<div class="layui-upload">
            <button class="layui-btn" id="test1" type="button">上传图片</button>
            <div class="layui-upload-list">
                <img class="layui-upload-img" src="@OrderInfo.Product_Name" id="demo1" style="width:200px;height:200px" />
                <p id="demoText"></p>
            </div>
        </div>*@
        <div class="layui-form-item">
            <label class="layui-form-label">产品名称</label>
            <div class="layui-input-inline">
                <input type="text" id="PicUrl" value="@OrderInfo.Product_Name" name="title" placeholder="" autocomplete="off" class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">订单编号</label>
            <div class="layui-input-block">
                <input type="text" id="Order_No" value="@OrderInfo.Order_No" class="layui-input linksName" lay-verify="required" placeholder="请输入品牌名称" />
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">总价</label>
                <div class="layui-input-inline">
                    <input type="text" id="Order_Money" value="@OrderInfo.Order_Money" class="layui-input linksTime" lay-verify="date" onclick="layui.laydate({elem:this})" />
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">优惠金额</label>
            <div class="layui-input-block">
                <input type="text" id="District_Money" value="@OrderInfo.District_Money" class="layui-input masterEmail" lay-verify="email" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否发货</label>
            <div class="layui-input-block">
                @if (OrderInfo.Order_Status == 0)
                {
                    <input type="checkbox" id="Status" value="@OrderInfo.Order_Status" name="state" lay-text="开启|关闭" lay-skin="switch">
                }
                else
                {
                    <input type="checkbox" id="Status" value="@OrderInfo.Order_Status" name="state" lay-text="开启|关闭" checked lay-skin="switch">
                }
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">数量</label>
            <div class="layui-input-block">
                <input type="text" id="Product_Cnt" value="@OrderInfo.Product_Cnt" class="layui-input masterEmail" lay-verify="email" />
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <input class="layui-btn" type="button" value="立即提交" id="commit" />
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <script type="text/javascript" src="~/layui-v2.5.4/layui/layui.js"></script>
    <script type="text/javascript" src="~/js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="~/js/linksAdd.js"></script>
    <script src="~/layui-v2.5.4/layui/lay/modules/layer.js"></script>
    <script src="~/static/admin/js/script.js"></script>
    <script>
        //jquery指定别名
        var $ = jQuery.noConflict();

        $(function () {
            $("#commit").click(function () {
                //获取值
                var data = {};
                data.Order_Status = 0;
                if ($("#Status").prop("checked")) {
                    data.Order_Status = 1;
                }
                data.Order_Id = $("#Id").val();
                data.Order_No = $("#Order_No").val();
                data.Order_Money = $("#Order_Money").val();
                data.Product_Name = $("#PicUrl").val();
                data.Product_Cnt = $("#Product_Cnt").val();
                data.District_Money = $("#District_Money").val();
                $.ajax({
                    url: "/Order/EditOrderInfo",
                    type: "post",
                    data: data,
                    success: function (data) {
                        if (data.Success) {
                            layer.msg('编辑成功！', {
                                title: '提示框',
                                icon: 1,
                                time: 2000
                            }, function () {
                                location.href = "/Home/Order_Form";
                            });
                        }
                        else {
                            layer.msg('编辑失败！', {
                                title: '提示框',
                                icon: 1,
                                time: 2000
                            });
                        }
                    }
                });
            });
        });


        layui.use('upload', function () {
            var $ = layui.jquery
                , upload = layui.upload;
            //普通图片上传
            var uploadInst = upload.render({
                elem: '#test1'
                , url: '/Brand/UploadImage'
                , before: function (obj) {
                    //预读本地文件示例，不支持ie8
                    obj.preview(function (index, file, result) {
                        $('#demo1').attr('src', result); //图片链接（base64）
                    });
                }
                , done: function (res) {
                    //如果上传失败
                    if (res.code > 0) {
                        return layer.msg('上传失败');
                    }
                    else {
                        //上传成功,获取图片路径
                        $("#PicUrl").val(res.FilePath);
                    }
                }
            });
        });
    </script>
</body>
</html>


